#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)

#include <stdio.h>

/**
 * Note: The returned array must be malloced, assume caller calls free().
 */

int Judgement(int num)
{
    int digit[5] = { 0 };
    int tmp = num;
    int j = 0;
    int i = 0;

    while (tmp != 0)
    {
        digit[j] = tmp % 10;
        if (digit[j] == 0)
        {
            return 0;
        }
        tmp = tmp / 10;
        j++;
    }

    for (i = 0; i < j; i++)
    {
        if (num % digit[i] != 0)
        {
            return 0;
        }
    }

    return num;
}

int* selfDividingNumbers(int left, int right, int* returnSize)
{
    int* object = (int*)malloc(10000 * sizeof(int));
    int j = 0;
    int i = left;
    int result = 0;

    for (i = left; i <= right; i++)
    {
        result = Judgement(i);
        if (result != 0)
        {
            object[j] = result;
            j++;
        }
    }

    return object;
}

int main()
{
    //int* test = selfDividingNumbers(1, 22, )

    return 0;
}